/**
 * 
 */
package edu.bucknell.edash;


import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

/**
 * Fragment for the secondary screen
 * @author abb011
 *
 */
public class SecondaryScreen extends Fragment {
	
	/*
	 * Creating Gauges
	 */
	public Gauge auxCurrent;
	public Gauge speed;
	public Gauge auxVoltageGauge;
	
	
	public static Fragment newInstance(Context context) {
		SecondaryScreen f = new SecondaryScreen();	
		
		return f;
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
		/*
		 * Telling which XML file to create the fragment from
		 */
		ViewGroup root = (ViewGroup) inflater.inflate(R.layout.secondary_screen, null);		
		
		/*
		 * Reading Gauges in from XML file
		 */
		auxCurrent = (Gauge) root.findViewById(R.id.auxCurrentGauge);
		speed = (Gauge)root.findViewById(R.id.speedGauge);
		auxVoltageGauge = (Gauge)root.findViewById(R.id.auxVoltGauge);

		/*
		 * Tying the Gauges to the Gauges in the MainActivity so that the MainActivity can control them 
		 */
		EdashMain main = (EdashMain) getActivity();
		main.gAuxCurrent = auxCurrent;
		main.gSpeed = speed;
		main.gAuxVoltage = auxVoltageGauge;

		//Returning frame
		return root;
	}
}
